<?php

	require_once "googledocs/GoogleDocsLoader.php";
	require_once "odt/OdtFile.php";

	/**
	 * Load a google document as a document node.
	 */
	class GoogleDocsNodeLoader {

		private $loader;
		private $parser;

		/**
		 * Set Authentication.
		 */
		public function setLoader($value) {
			$this->loader=$value;
		}

		/**
		 * Set document node parser.
		 */
		public function setParser($parser) {
			$this->parser=$parser;
		}

		/**
		 * Load a document.
		 */
		public function loadDocumentNode($id) {
			$filename=sys_get_temp_dir()."/odt".rand();
			file_put_contents($filename,$this->loader->loadDocument($id));
			$odt=new OdtFile($filename);
			unlink($filename);

			return $this->parser->parseOdt($odt);
		}
	}
?>